import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { NewsService } from '../../service/news.service';
import { News } from '../../model/news';

@Component({
  selector: 'app-managelistforuser',
  templateUrl: './managelistforuser.component.html',
  styleUrls: ['./managelistforuser.component.css']
})
export class ManagelistforuserComponent implements OnInit {
  nl:Array<News>;
  constructor(
    private newsservice:NewsService,
    private router:Router
  ) { }

  ngOnInit() {
   
    this.loadnewslist();
  }

  private loadnewslist(){
    this.nl=new Array();
    this.newsservice.getNewsList()
    .then((data:any)=>{
      this.nl=data;
    })
  
  }


  toDetail(id:string){
    this.router.navigate(['detail',id]);
  }


}
